var express = require('express');
var router = express.Router();
const { Login, Register, getUsers,getUsersById,changeUsersSeller } = require('../service/usersService');
/* GET users listing. */
router.post('/login', async function (req, res, next) {
  console.log('接收登录请求');
  const data = await Login(req.body);
  res.send(data);
});

router.post('/register', async function (req, res, next) {
  console.log('接收注册请求');
  const data = await Register(req.body);
  res.send(data);
});


// 获取所有客户
router.get('/getUsers', async function (req, res, next) {
  const data = await getUsers(req.query);
  console.log(req.query);
  res.send(data);
});



// 根据_id获取客户详细数据
router.get('/getUsersById', async function (req, res, next) {
  const data = await getUsersById(req.query);
  res.send(data);
});

// 根据修改客户的销售
router.post('/changeUsersSeller', async function (req, res, next) {
  const data = await changeUsersSeller(req.body);
  res.send(data);
});


module.exports = router;
